package ms.maplestory.boot.loaders.container;

import lombok.Getter;
import lombok.Setter;
import ms.maplestory.boot.client.character.quest.progress.QuestProgressRequirement;
import ms.maplestory.boot.client.character.quest.reward.QuestReward;
import ms.maplestory.boot.client.character.quest.requirement.QuestStartRequirement;

import java.util.HashSet;
import java.util.Set;

@Getter
@Setter
public class QuestInfo {

    private int id;
    private int startNpc;
    private int endNpc;
    private int infoNumber;
    private int fieldSetKeepTime;
    private int subJobFlags;
    private int morph;
    private int skill;
    private int nextQuest;
    private int viewMedalItem;
    private long start;
    private long end;
    private String startScript;
    private String endScript;
    private String fieldSet;
    private boolean normalAutoStart;
    private boolean autoStart;
    private boolean autoComplete;

    private Set<QuestStartRequirement> questStartRequirements = new HashSet<>();
    private Set<QuestProgressRequirement> questProgressRequirements = new HashSet<>();
    private Set<Integer> fieldEnters = new HashSet<>();
    private Set<QuestReward> questRewards = new HashSet<>();

    public void addRequirement(QuestStartRequirement questStartRequirement) {
        questStartRequirements.add(questStartRequirement);
    }

    public void addProgressRequirement(QuestProgressRequirement questProgressRequirement) {
        questProgressRequirements.add(questProgressRequirement);
    }

    public void addFieldEnter(int fieldID) {
        fieldEnters.add(fieldID);
    }

    public void addReward(QuestReward questReward) {
        questRewards.add(questReward);
    }

    public String getStartScript() {
        return startScript == null ? "" : startScript;
    }

    public String getEndScript() {
        return endScript == null ? "" : endScript;
    }

    public String getFieldSet() {
        return fieldSet == null ? "" : fieldSet;
    }

    @Override
    public String toString() {
        return String.format("ID: %d, startNpc: %d", id, startNpc);
    }
}
